/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/
import { index } from "@ohos/protobufjs"; const $protobuf = index;
import Long from 'long';
$protobuf.util.Long=Long
$protobuf.configure()

// Common aliases
const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

export const UserInfoResp = $root.UserInfoResp = (() => {

    /**
     * Properties of a UserInfoResp.
     * @exports IUserInfoResp
     * @interface IUserInfoResp
     * @property {string|null} [userCode] UserInfoResp userCode
     * @property {string|null} [username] UserInfoResp username
     * @property {string|null} [phone] UserInfoResp phone
     * @property {string|null} [mail] UserInfoResp mail
     * @property {string|null} [avatar] UserInfoResp avatar
     * @property {string|null} [token] UserInfoResp token
     * @property {Array.<IPair>|null} [roles] UserInfoResp roles
     */

    /**
     * Constructs a new UserInfoResp.
     * @exports UserInfoResp
     * @classdesc Represents a UserInfoResp.
     * @implements IUserInfoResp
     * @constructor
     * @param {IUserInfoResp=} [properties] Properties to set
     */
    function UserInfoResp(properties) {
        this.roles = [];
        if (properties)
            for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                if (properties[keys[i]] != null)
                    this[keys[i]] = properties[keys[i]];
    }

    /**
     * UserInfoResp userCode.
     * @member {string} userCode
     * @memberof UserInfoResp
     * @instance
     */
    UserInfoResp.prototype.userCode = "";

    /**
     * UserInfoResp username.
     * @member {string} username
     * @memberof UserInfoResp
     * @instance
     */
    UserInfoResp.prototype.username = "";

    /**
     * UserInfoResp phone.
     * @member {string} phone
     * @memberof UserInfoResp
     * @instance
     */
    UserInfoResp.prototype.phone = "";

    /**
     * UserInfoResp mail.
     * @member {string} mail
     * @memberof UserInfoResp
     * @instance
     */
    UserInfoResp.prototype.mail = "";

    /**
     * UserInfoResp avatar.
     * @member {string} avatar
     * @memberof UserInfoResp
     * @instance
     */
    UserInfoResp.prototype.avatar = "";

    /**
     * UserInfoResp token.
     * @member {string} token
     * @memberof UserInfoResp
     * @instance
     */
    UserInfoResp.prototype.token = "";

    /**
     * UserInfoResp roles.
     * @member {Array.<IPair>} roles
     * @memberof UserInfoResp
     * @instance
     */
    UserInfoResp.prototype.roles = $util.emptyArray;

    /**
     * Creates a new UserInfoResp instance using the specified properties.
     * @function create
     * @memberof UserInfoResp
     * @static
     * @param {IUserInfoResp=} [properties] Properties to set
     * @returns {UserInfoResp} UserInfoResp instance
     */
    UserInfoResp.create = function create(properties) {
        return new UserInfoResp(properties);
    };

    /**
     * Encodes the specified UserInfoResp message. Does not implicitly {@link UserInfoResp.verify|verify} messages.
     * @function encode
     * @memberof UserInfoResp
     * @static
     * @param {IUserInfoResp} message UserInfoResp message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    UserInfoResp.encode = function encode(message, writer) {
        if (!writer)
            writer = $Writer.create();
        if (message.userCode != null && Object.hasOwnProperty.call(message, "userCode"))
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.userCode);
        if (message.username != null && Object.hasOwnProperty.call(message, "username"))
            writer.uint32(/* id 2, wireType 2 =*/18).string(message.username);
        if (message.phone != null && Object.hasOwnProperty.call(message, "phone"))
            writer.uint32(/* id 3, wireType 2 =*/26).string(message.phone);
        if (message.mail != null && Object.hasOwnProperty.call(message, "mail"))
            writer.uint32(/* id 4, wireType 2 =*/34).string(message.mail);
        if (message.avatar != null && Object.hasOwnProperty.call(message, "avatar"))
            writer.uint32(/* id 5, wireType 2 =*/42).string(message.avatar);
        if (message.token != null && Object.hasOwnProperty.call(message, "token"))
            writer.uint32(/* id 6, wireType 2 =*/50).string(message.token);
        if (message.roles != null && message.roles.length)
            for (let i = 0; i < message.roles.length; ++i)
                $root.Pair.encode(message.roles[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim();
        return writer;
    };

    /**
     * Encodes the specified UserInfoResp message, length delimited. Does not implicitly {@link UserInfoResp.verify|verify} messages.
     * @function encodeDelimited
     * @memberof UserInfoResp
     * @static
     * @param {IUserInfoResp} message UserInfoResp message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    UserInfoResp.encodeDelimited = function encodeDelimited(message, writer) {
        return this.encode(message, writer).ldelim();
    };

    /**
     * Decodes a UserInfoResp message from the specified reader or buffer.
     * @function decode
     * @memberof UserInfoResp
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @param {number} [length] Message length if known beforehand
     * @returns {UserInfoResp} UserInfoResp
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    UserInfoResp.decode = function decode(reader, length) {
        if (!(reader instanceof $Reader))
            reader = $Reader.create(reader);
        let end = length === undefined ? reader.len : reader.pos + length, message = new $root.UserInfoResp();
        while (reader.pos < end) {
            let tag = reader.uint32();
            switch (tag >>> 3) {
            case 1: {
                    message.userCode = reader.string();
                    break;
                }
            case 2: {
                    message.username = reader.string();
                    break;
                }
            case 3: {
                    message.phone = reader.string();
                    break;
                }
            case 4: {
                    message.mail = reader.string();
                    break;
                }
            case 5: {
                    message.avatar = reader.string();
                    break;
                }
            case 6: {
                    message.token = reader.string();
                    break;
                }
            case 7: {
                    if (!(message.roles && message.roles.length))
                        message.roles = [];
                    message.roles.push($root.Pair.decode(reader, reader.uint32()));
                    break;
                }
            default:
                reader.skipType(tag & 7);
                break;
            }
        }
        return message;
    };

    /**
     * Decodes a UserInfoResp message from the specified reader or buffer, length delimited.
     * @function decodeDelimited
     * @memberof UserInfoResp
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @returns {UserInfoResp} UserInfoResp
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    UserInfoResp.decodeDelimited = function decodeDelimited(reader) {
        if (!(reader instanceof $Reader))
            reader = new $Reader(reader);
        return this.decode(reader, reader.uint32());
    };

    /**
     * Verifies a UserInfoResp message.
     * @function verify
     * @memberof UserInfoResp
     * @static
     * @param {Object.<string,*>} message Plain object to verify
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
     */
    UserInfoResp.verify = function verify(message) {
        if (typeof message !== "object" || message === null)
            return "object expected";
        if (message.userCode != null && message.hasOwnProperty("userCode"))
            if (!$util.isString(message.userCode))
                return "userCode: string expected";
        if (message.username != null && message.hasOwnProperty("username"))
            if (!$util.isString(message.username))
                return "username: string expected";
        if (message.phone != null && message.hasOwnProperty("phone"))
            if (!$util.isString(message.phone))
                return "phone: string expected";
        if (message.mail != null && message.hasOwnProperty("mail"))
            if (!$util.isString(message.mail))
                return "mail: string expected";
        if (message.avatar != null && message.hasOwnProperty("avatar"))
            if (!$util.isString(message.avatar))
                return "avatar: string expected";
        if (message.token != null && message.hasOwnProperty("token"))
            if (!$util.isString(message.token))
                return "token: string expected";
        if (message.roles != null && message.hasOwnProperty("roles")) {
            if (!Array.isArray(message.roles))
                return "roles: array expected";
            for (let i = 0; i < message.roles.length; ++i) {
                let error = $root.Pair.verify(message.roles[i]);
                if (error)
                    return "roles." + error;
            }
        }
        return null;
    };

    /**
     * Creates a UserInfoResp message from a plain object. Also converts values to their respective internal types.
     * @function fromObject
     * @memberof UserInfoResp
     * @static
     * @param {Object.<string,*>} object Plain object
     * @returns {UserInfoResp} UserInfoResp
     */
    UserInfoResp.fromObject = function fromObject(object) {
        if (object instanceof $root.UserInfoResp)
            return object;
        let message = new $root.UserInfoResp();
        if (object.userCode != null)
            message.userCode = String(object.userCode);
        if (object.username != null)
            message.username = String(object.username);
        if (object.phone != null)
            message.phone = String(object.phone);
        if (object.mail != null)
            message.mail = String(object.mail);
        if (object.avatar != null)
            message.avatar = String(object.avatar);
        if (object.token != null)
            message.token = String(object.token);
        if (object.roles) {
            if (!Array.isArray(object.roles))
                throw TypeError(".UserInfoResp.roles: array expected");
            message.roles = [];
            for (let i = 0; i < object.roles.length; ++i) {
                if (typeof object.roles[i] !== "object")
                    throw TypeError(".UserInfoResp.roles: object expected");
                message.roles[i] = $root.Pair.fromObject(object.roles[i]);
            }
        }
        return message;
    };

    /**
     * Creates a plain object from a UserInfoResp message. Also converts values to other types if specified.
     * @function toObject
     * @memberof UserInfoResp
     * @static
     * @param {UserInfoResp} message UserInfoResp
     * @param {$protobuf.IConversionOptions} [options] Conversion options
     * @returns {Object.<string,*>} Plain object
     */
    UserInfoResp.toObject = function toObject(message, options) {
        if (!options)
            options = {};
        let object = {};
        if (options.arrays || options.defaults)
            object.roles = [];
        if (options.defaults) {
            object.userCode = "";
            object.username = "";
            object.phone = "";
            object.mail = "";
            object.avatar = "";
            object.token = "";
        }
        if (message.userCode != null && message.hasOwnProperty("userCode"))
            object.userCode = message.userCode;
        if (message.username != null && message.hasOwnProperty("username"))
            object.username = message.username;
        if (message.phone != null && message.hasOwnProperty("phone"))
            object.phone = message.phone;
        if (message.mail != null && message.hasOwnProperty("mail"))
            object.mail = message.mail;
        if (message.avatar != null && message.hasOwnProperty("avatar"))
            object.avatar = message.avatar;
        if (message.token != null && message.hasOwnProperty("token"))
            object.token = message.token;
        if (message.roles && message.roles.length) {
            object.roles = [];
            for (let j = 0; j < message.roles.length; ++j)
                object.roles[j] = $root.Pair.toObject(message.roles[j], options);
        }
        return object;
    };

    /**
     * Converts this UserInfoResp to JSON.
     * @function toJSON
     * @memberof UserInfoResp
     * @instance
     * @returns {Object.<string,*>} JSON object
     */
    UserInfoResp.prototype.toJSON = function toJSON() {
        return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
    };

    /**
     * Gets the default type url for UserInfoResp
     * @function getTypeUrl
     * @memberof UserInfoResp
     * @static
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
     * @returns {string} The default type url
     */
    UserInfoResp.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
        if (typeUrlPrefix === undefined) {
            typeUrlPrefix = "type.googleapis.com";
        }
        return typeUrlPrefix + "/UserInfoResp";
    };

    return UserInfoResp;
})();

export const Pair = $root.Pair = (() => {

    /**
     * Properties of a Pair.
     * @exports IPair
     * @interface IPair
     * @property {string|null} [first] Pair first
     * @property {number|Long|null} [second] Pair second
     */

    /**
     * Constructs a new Pair.
     * @exports Pair
     * @classdesc Represents a Pair.
     * @implements IPair
     * @constructor
     * @param {IPair=} [properties] Properties to set
     */
    function Pair(properties) {
        if (properties)
            for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i)
                if (properties[keys[i]] != null)
                    this[keys[i]] = properties[keys[i]];
    }

    /**
     * Pair first.
     * @member {string} first
     * @memberof Pair
     * @instance
     */
    Pair.prototype.first = "";

    /**
     * Pair second.
     * @member {number|Long} second
     * @memberof Pair
     * @instance
     */
    Pair.prototype.second = $util.Long ? $util.Long.fromBits(0,0,false) : 0;

    /**
     * Creates a new Pair instance using the specified properties.
     * @function create
     * @memberof Pair
     * @static
     * @param {IPair=} [properties] Properties to set
     * @returns {Pair} Pair instance
     */
    Pair.create = function create(properties) {
        return new Pair(properties);
    };

    /**
     * Encodes the specified Pair message. Does not implicitly {@link Pair.verify|verify} messages.
     * @function encode
     * @memberof Pair
     * @static
     * @param {IPair} message Pair message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    Pair.encode = function encode(message, writer) {
        if (!writer)
            writer = $Writer.create();
        if (message.first != null && Object.hasOwnProperty.call(message, "first"))
            writer.uint32(/* id 1, wireType 2 =*/10).string(message.first);
        if (message.second != null && Object.hasOwnProperty.call(message, "second"))
            writer.uint32(/* id 2, wireType 0 =*/16).int64(message.second);
        return writer;
    };

    /**
     * Encodes the specified Pair message, length delimited. Does not implicitly {@link Pair.verify|verify} messages.
     * @function encodeDelimited
     * @memberof Pair
     * @static
     * @param {IPair} message Pair message or plain object to encode
     * @param {$protobuf.Writer} [writer] Writer to encode to
     * @returns {$protobuf.Writer} Writer
     */
    Pair.encodeDelimited = function encodeDelimited(message, writer) {
        return this.encode(message, writer).ldelim();
    };

    /**
     * Decodes a Pair message from the specified reader or buffer.
     * @function decode
     * @memberof Pair
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @param {number} [length] Message length if known beforehand
     * @returns {Pair} Pair
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    Pair.decode = function decode(reader, length) {
        if (!(reader instanceof $Reader))
            reader = $Reader.create(reader);
        let end = length === undefined ? reader.len : reader.pos + length, message = new $root.Pair();
        while (reader.pos < end) {
            let tag = reader.uint32();
            switch (tag >>> 3) {
            case 1: {
                    message.first = reader.string();
                    break;
                }
            case 2: {
                    message.second = reader.int64();
                    break;
                }
            default:
                reader.skipType(tag & 7);
                break;
            }
        }
        return message;
    };

    /**
     * Decodes a Pair message from the specified reader or buffer, length delimited.
     * @function decodeDelimited
     * @memberof Pair
     * @static
     * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
     * @returns {Pair} Pair
     * @throws {Error} If the payload is not a reader or valid buffer
     * @throws {$protobuf.util.ProtocolError} If required fields are missing
     */
    Pair.decodeDelimited = function decodeDelimited(reader) {
        if (!(reader instanceof $Reader))
            reader = new $Reader(reader);
        return this.decode(reader, reader.uint32());
    };

    /**
     * Verifies a Pair message.
     * @function verify
     * @memberof Pair
     * @static
     * @param {Object.<string,*>} message Plain object to verify
     * @returns {string|null} `null` if valid, otherwise the reason why it is not
     */
    Pair.verify = function verify(message) {
        if (typeof message !== "object" || message === null)
            return "object expected";
        if (message.first != null && message.hasOwnProperty("first"))
            if (!$util.isString(message.first))
                return "first: string expected";
        if (message.second != null && message.hasOwnProperty("second"))
            if (!$util.isInteger(message.second) && !(message.second && $util.isInteger(message.second.low) && $util.isInteger(message.second.high)))
                return "second: integer|Long expected";
        return null;
    };

    /**
     * Creates a Pair message from a plain object. Also converts values to their respective internal types.
     * @function fromObject
     * @memberof Pair
     * @static
     * @param {Object.<string,*>} object Plain object
     * @returns {Pair} Pair
     */
    Pair.fromObject = function fromObject(object) {
        if (object instanceof $root.Pair)
            return object;
        let message = new $root.Pair();
        if (object.first != null)
            message.first = String(object.first);
        if (object.second != null)
            if ($util.Long)
                (message.second = $util.Long.fromValue(object.second)).unsigned = false;
            else if (typeof object.second === "string")
                message.second = parseInt(object.second, 10);
            else if (typeof object.second === "number")
                message.second = object.second;
            else if (typeof object.second === "object")
                message.second = new $util.LongBits(object.second.low >>> 0, object.second.high >>> 0).toNumber();
        return message;
    };

    /**
     * Creates a plain object from a Pair message. Also converts values to other types if specified.
     * @function toObject
     * @memberof Pair
     * @static
     * @param {Pair} message Pair
     * @param {$protobuf.IConversionOptions} [options] Conversion options
     * @returns {Object.<string,*>} Plain object
     */
    Pair.toObject = function toObject(message, options) {
        if (!options)
            options = {};
        let object = {};
        if (options.defaults) {
            object.first = "";
            if ($util.Long) {
                let long = new $util.Long(0, 0, false);
                object.second = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long;
            } else
                object.second = options.longs === String ? "0" : 0;
        }
        if (message.first != null && message.hasOwnProperty("first"))
            object.first = message.first;
        if (message.second != null && message.hasOwnProperty("second"))
            if (typeof message.second === "number")
                object.second = options.longs === String ? String(message.second) : message.second;
            else
                object.second = options.longs === String ? $util.Long.prototype.toString.call(message.second) : options.longs === Number ? new $util.LongBits(message.second.low >>> 0, message.second.high >>> 0).toNumber() : message.second;
        return object;
    };

    /**
     * Converts this Pair to JSON.
     * @function toJSON
     * @memberof Pair
     * @instance
     * @returns {Object.<string,*>} JSON object
     */
    Pair.prototype.toJSON = function toJSON() {
        return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
    };

    /**
     * Gets the default type url for Pair
     * @function getTypeUrl
     * @memberof Pair
     * @static
     * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
     * @returns {string} The default type url
     */
    Pair.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
        if (typeUrlPrefix === undefined) {
            typeUrlPrefix = "type.googleapis.com";
        }
        return typeUrlPrefix + "/Pair";
    };

    return Pair;
})();

export { $root as default };
